package com.ruoyi.fs.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fs.mapper.FsClientMapper;
import com.ruoyi.fs.domain.FsClient;
import com.ruoyi.fs.service.IFsClientService;

/**
 * 当事人Service业务层处理
 * 
 * @author hero
 * @date 2024-08-30
 */
@Service
public class FsClientServiceImpl implements IFsClientService 
{
    @Autowired
    private FsClientMapper fsClientMapper;

    /**
     * 查询当事人
     * 
     * @param id 当事人主键
     * @return 当事人
     */
    @Override
    public FsClient selectFsClientById(Long id)
    {
        return fsClientMapper.selectFsClientById(id);
    }

    /**
     * 查询当事人
     *
     * @param bh 当事人主键
     * @return 当事人
     */
    @Override
    public FsClient selectFsClientByBh(String bh) {
        FsClient query = new FsClient();
        query.setBh(bh);
        List<FsClient> list = fsClientMapper.selectFsClientList(query);
        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }
    }

    /**
     * 查询当事人列表
     * 
     * @param fsClient 当事人
     * @return 当事人
     */
    @Override
    public List<FsClient> selectFsClientList(FsClient fsClient)
    {
        return fsClientMapper.selectFsClientList(fsClient);
    }

    /**
     * 新增当事人
     * 
     * @param fsClient 当事人
     * @return 结果
     */
    @Override
    public int insertFsClient(FsClient fsClient)
    {
        fsClient.setCreateTime(DateUtils.getNowDate());
        return fsClientMapper.insertFsClient(fsClient);
    }

    /**
     * 修改当事人
     * 
     * @param fsClient 当事人
     * @return 结果
     */
    @Override
    public int updateFsClient(FsClient fsClient)
    {
        fsClient.setUpdateTime(DateUtils.getNowDate());
        return fsClientMapper.updateFsClient(fsClient);
    }

    /**
     * 批量删除当事人
     * 
     * @param ids 需要删除的当事人主键
     * @return 结果
     */
    @Override
    public int deleteFsClientByIds(Long[] ids)
    {
        return fsClientMapper.deleteFsClientByIds(ids);
    }

    /**
     * 删除当事人信息
     * 
     * @param id 当事人主键
     * @return 结果
     */
    @Override
    public int deleteFsClientById(Long id)
    {
        return fsClientMapper.deleteFsClientById(id);
    }
}
